"regex 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
"semver 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)",
- "tar 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "tar 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"tempdir 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
"term 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
+[[package]]
+name = "libc"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
[[package]]
name = "libgit2-sys"
version = "0.3.6"
[[package]]
name = "tar"
-version = "0.3.1"
+version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"filetime 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
for file in try!(src.list_files(pkg)).iter() {
if &**file == dst { continue }
let relative = util::without_prefix(&file, &root).unwrap();
+ try!(check_filename(relative));
let relative = try!(relative.to_str().chain_error(|| {
human(format!("non-utf8 path in source directory: {}",
relative.display()))
Ok(())
}
+
+// It can often be the case that files of a particular name on one platform
+// can't actually be created on another platform. For example files with colons
+// in the name are allowed on Unix but not on Windows.
+//
+// To help out in situations like this, issue about weird filenames when
+// packaging as a "heads up" that something may not work on other platforms.
+fn check_filename(file: &Path) -> CargoResult<()> {
+ let name = match file.file_name() {
+ Some(name) => name,
+ None => return Ok(()),
+ };
+ let name = match name.to_str() {
+ Some(name) => name,
+ None => {
+ return Err(human(format!("path does not have a unicode filename \
+ which may not unpack on all platforms: {}",
+ file.display())))
+ }
+ };
+ let bad_chars = ['/', '\\', '<', '>', ':', '"', '|', '?', '*'];
+ for c in bad_chars.iter().filter(|c| name.contains(**c)) {
+ return Err(human(format!("cannot package a filename with a special \
+ character `{}`: {}", c, file.display())))
+ }
+ Ok(())
+}
"unexpected filename: {:?}", f.header().path())
}
});
+
+#[cfg(unix)] // windows doesn't allow these characters in filenames
+test!(package_weird_characters {
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ [project]
+ name = "foo"
+ version = "0.0.1"
+ authors = []
+ "#)
+ .file("src/main.rs", r#"
+ fn main() { println!("hello"); }
+ "#)
+ .file("src/:foo", "");
+
+ assert_that(p.cargo_process("package"),
+ execs().with_status(101).with_stderr("\
+warning: [..]
+failed to prepare local package for uploading
+
+Caused by:
+ cannot package a filename with a special character `:`: src/:foo
+"));
+});